package com.cserver.pro.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Component
public class LogAspect {

    @Pointcut("execution(* com.cserver.pro.service.impl.*.*(..))")
    public void pointCut(){}

    @Before("pointCut()")
    public void beforMethod(JoinPoint joinPoint){

        System.out.println("-------------->before"+joinPoint.getTarget().getClass().getName()+"."+joinPoint.getSignature().getName()+"==="+ Arrays.asList(joinPoint.getArgs()));
    }
    @After("pointCut()")
    public void afterMethod(){
        System.out.println("-=-=-=-=-=》after");
    }

    @AfterReturning(value = "pointCut()",returning = "result")
    public void returnMethod(Object result){
        System.out.println("======》returnMethod"+result);
    }

    @AfterThrowing(value = "pointCut()",throwing = "exception")
    public void throwingMethod(Throwable exception){
        System.out.println("异常"+exception);
    }
}
